/*检测是否是数组*/
window.is_array=function(argument){
    return argument && (typeof argument==="object") && ("length" in argument) && (typeof argument.length==="number") ?true : false ;
    /*return ("isArray" in Array) && (Array.isArray(argument))*/
    /*return Object.prototype.toString.call(argument)==="[object Array]"*/
}
/*检测是否是对象*/
window.is_object=function(argument){
    if (argument && (typeof argument==="object") && ("length" in argument)) {
        return Object.prototype.toString.call(argument)==="[object Object]";
    }
    return argument && (typeof argument==="object") && !("length" in argument) ? true : false ;
}
/*检测是否是函数*/
window.is_function=function(argument){
    return argument && typeof argument==="function" ? true : false ;
}
/*检测是否是字符串*/
window.is_string=function(argument){
    return argument && typeof argument==="string" ? true : false ;
}
/*检测是否是布尔值*/
window.is_boolean=function(argument){
    return typeof argument==="boolean" ? true : false ;
}
/*检测是否是数字（数值）*/
window.is_number=function(argument){
    return typeof argument==="number" ? true : false ;
}
/*检测是否是未定义*/
window.is_undefined=function(argument){
    return typeof argument==="undefined" ? true : false;
}
/*检测是否是为空*/
window.is_null=function(argument){
    return argument===null || argument==="" ? true : false;
}
var _this=this;
/*
**@array_or_json array|object 数组或对象 @fun function 回调函数
**@fun回调函数要三个参数表示： 数组（或对象）,下标（key），value
*/
window.foreach=function(array_or_json,fun){
    if (is_array(array_or_json)) {
        if (typeof fun==="function") {
            for(var i=0,len=array_or_json.length;i<len;i++){
                fun(array_or_json,i,array_or_json[i]);
            }
        }

    }
    if (is_object(array_or_json)) {
        if (typeof fun==="function") {
            for(var att in array_or_json){
                fun(array_or_json,att,array_or_json[att]);
            }
        }
    }
}
/*
**随机数	@begin_number number 最小数字 @end_number nunber 最大数字
*/
window.random=function(begin_number,end_number){
    (begin_number) 	|| 	(begin_number=0);
    (end_number)	||	(end_number=10);
    return  (end_number>=begin_number) ? ~~(Math.random()*(end_number-begin_number+1)) + ~~(begin_number) : false ;
}
/*随机字符串*/
window.randomString=function(l,mode,C){
    (l) 	|| (l=5);
    (mode) 	|| (mode="n");
    var value={
        /*数字*/
        n: 		"0123456789"
        /*小写字母*/
        ,s: 	"abcdefghijklmnopqrstuvwxyz"
        /*大写字母*/
        ,S: 	"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        /*数字和小写字母*/
        ,ns: 	"0123456789abcdefghijklmnopqrstuvwxyz"
        /*数字和大写字母*/
        ,nS: 	"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        /*小写字母和大写字母*/
        ,sS: 	"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
        /*数字和小写字母和大写字母*/
        ,nsS: 	"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
        /*其他字符包括数字小写和大写*/
        ,all: 	"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_+-*=^~,#$@|!"
    };
    if (is_object(C)) {
        foreach(C,function(c,k,v){
            value[k]=v;
        });
    }
    (value[mode]) || (mode="n");
    var str="";
    for(var i=0,str_len=value[mode].length;i<l;i++){
        str+=value[mode][~~(Math.random()*str_len)];
    }
    return str;
}
/*
**给对象添加属性（也可以给标签元素【DOM】对象属性）
**@obj object 对象或者json格式 @json_attribute  object 对象或者json格式
*/
window.set_obj_att=function(obj,json_attribute){
    if( is_object(obj) && is_object(json_attribute)){
        for(var att in json_attribute){
            is_object(json_attribute[att]) ? this.set_obj_att(obj[att]={},json_attribute[att]) : obj[att]=json_attribute[att];
        }
    }
}
/*
*插入元素
*@parentElement object 父元素 @element_name string 要创建的元素名称 @ele_att object(json格式) 设置创建元素的属性
*@refer_node object 兄弟元素(是否把新建的元素节点插入兄弟元素节点的前面,值可以为空) @fun function 回调函数（传入两个参数,值可以为空）
*/
window.insertElement=function(parentElement,element_name,ele_att,refer_node,fun){
    if (parentElement&&element_name) {
        var E=document.createElement(element_name);
        this.set_obj_att(E,ele_att);
        if (is_object(ele_att["myAttribute"])) {
            foreach(ele_att["myAttribute"],function(json,key,value){
                E.setAttribute(key,value);
            });
        }
        (fun&&typeof fun=="function")&&(fun(E,this));
        refer_node ? parentElement.insertBefore(E,refer_node) : parentElement.appendChild(E);
        return true;
    }
    else{
        return false;
    }
}
/*简单给特定的json数据编码为特定的字符串
*@json object 对象，格式为 如：{key:"value",key1:"value1"},键值（属性值）只能为字符串格式
*@C object json格式，配置，设置分割标记字符串 @encode是否编码（encodeURIComponent），默认选择编码（值：true|"false"）
*/
window.en_str_json=function(json,C,encode){
    if (is_object(json)) {
        (encode)||(encode=true);
        (is_object(C))||(C={});
        /*键名和键值的分割标记*/
        (C.key)||(C.key="<=>");
        /*键名与键值跟键名与键值之间的分割标记*/
        (C.k_v)||(C.k_v="<,>");
        var str="";
        var keyL=C.key.length, k_vL=C.k_v.length;
        if (encode===true) {
            foreach(json,function(JSON,key,value){
                str+=key+C.key+encodeURIComponent(value)+C.k_v;
                //str+=key+C.key+(value)+C.k_v;
            });
            return str.substr(0,str.length-k_vL);
        }
        if (encode==="false") {
            foreach(json,function(JSON,key,value){
                str+=key+C.key+value+C.k_v;
            });
            return str.substr(0,str.length-k_vL);
        }
    }
    else{
        return false;
    }
}

window.ajax=function(json,fun){
    if (!is_object(json)) {
        return false;
    }
    (json.methon)||(json.methon="post");
    (json.action)||(json.action="");
    /*josn.jsonp 是否跨域请求*/
    (json.jsonp)||(json.jsonp=false);
    /*json.url 跨域请求的地址*/
    (json.url)	||(json.url="");
    /*设置回调函数名称 看后台接口而定,既设置函数名称的参数，百度的为cb(?cb=functionName)*/
    (json.functionName)||(json.functionName="jsonpData");
    (is_object(json.get))||(json.get={});
    (is_object(json.post))||(json.post={});
    if (json.jsonp===true) {
        insertElement(document.body,"script",{
            type:"text/javascript"
            ,className:"jsonp"
            ,src:json.url+"?functionName="+json.functionName+"&"+this.en_str_json(json.get,{key:"=",k_v:"&"})
        })
        return;
    }
    var xhr=new XMLHttpRequest();
    xhr.open(json.methon,json.action+"?"+this.en_str_json(json.get,{key:"=",k_v:"&"}),true);
    /*console.log(this.en_str_json(json.get,{key:"=",k_v:"&"}));*/
    /*设置请求头部*/
    xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xhr.send(this.en_str_json(json.post,{key:"=",k_v:"&"}));
    xhr.onreadystatechange=function(e){
        if(this.readyState==4&&this.status>=200){
            var texts=this.responseText;
            (typeof fun==="function")&&(fun.call(this,texts));
        }
    }
}

/*
*@time number 时间戳 @formate string 时间格式
*new Date("yyyy/mm/dd hh:ii:ss");
*/
window.dateFormat=function(time,format){
    var T=new Date();
    (time) || (time=T.getTime());
    (format)||(format="Y-M-D H:I:S");
    /*time=parseInt(time);*//*parseInt(time,10);*/
    T.setTime(time);
    var day=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
    var month={
        name:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]
        ,number:[1,2,3,4,5,6,7,8,9,10,11,12]
    }
    var data={
        /*四位数年份*/
        year:T.getFullYear()
        ,Y:T.getFullYear()
        /*月数 月份*/
        ,M:("0"+month.number[T.getMonth()]).slice(-2)
        ,m:month.number[T.getMonth()]
        ,month_name:month.name[T.getMonth()]
        /*星期几*/
        ,day:day[T.getDay()]
        /*天（日）*/
        ,D:("0"+T.getDate()).slice(-2)
        ,d:T.getDate()
        /*时*/
        ,H:("0"+T.getHours()).slice(-2)
        ,h:T.getHours()
        /*分*/
        ,I:("0"+T.getMinutes()).slice(-2)
        ,i:T.getMinutes()
        /*秒*/
        ,S:("0"+T.getSeconds()).slice(-2)
        ,s:T.getSeconds()
    };
    var replace_mode=data;
    foreach(replace_mode,function(obj,key,value){
        var preg=new RegExp(key,"g");
        /* key=key.replace(/\"/g,"\\\"");key=key.replace(/\//g,"\\\/");var preg=eval("/"+key+"/g");*/
        format=format.replace(preg,value);
    });
    return format;
}

/*unicode字符编码*/
window.enUnicode=function(strings){
    var unicode_str="";
    if (strings) {
        for(var i=0,len=strings.length;i<len;i++){
            var s="00"+strings.charCodeAt(i).toString(16);
            /*截取后面4个字符串*/
            s=s.slice(-4);
            unicode_str+="\\u"+s;
        }
        return unicode_str;
    }
    else{
        return false;
    }
}
/*解码unicode编码字符串*/
window.deUnicode=function(strings){
    strings = strings.replace(/\\/g, "%");
    //console.log(strings);
    return unescape(strings);
    /*return decodeURIComponent(strings);*/
}

/**
 * 复制内容到剪切板
 * @param {string} text
 * @returns {HTMLElement[]}
 */
window.copyText = function (text) {
    var E = document.createElement("textarea");
    E.value = text;
    E.setAttribute("style","position: fixed; top: 0px; left: -1920px;");
    document.body.appendChild(E);
    /*var currentFocus = document.activeElement;*/
    E.focus();
    /*全选对象里面的内容，跟 E.select()一样*/
    E.setSelectionRange(0,E.value.length);
    /*复制选中的文字到剪贴板*/
    document.execCommand('copy', true);
    E.focus();
    /*currentFocus.focus();*/
    document.body.removeChild(E);
    return [E];
};

/**
 * 本地缓存(localStorage或sessionStorage)操作,sessionStorage是关闭当前页面数据就清空 【构造函数】
 * @param{string} name 值为(localStorage|sessionStorage),默认localStorage
 */
function storage(name){
    (name)||(name="localStorage");
    this._Storage=window[name]; /* this._Storage=localStorage; 或 this._Storage=sessionStorage;*/
    /**
     * 添加或修改localStorage对象或者sessionStorage的属性(键名)内容
     * @param {string} key 键名(对象属性)
     * @param {string|array|object} value 添加或修改的数据
     * @param {boolean} is_encode 是否给字符串编码
     * @returns {storage}
     */
    this.set = function (key, value, is_encode) {
        /*默认给字符串编码*/
        if (!key) {
            return;
        }
        if (is_object(value) || is_array(value)) {
            this._Storage.setItem(key, is_encode ? encodeURIComponent(JSON.stringify(value)) : JSON.stringify(value));
            /*或者这样写: this._Storage[key]= is_encode ? JSON.stringify(value) : encodeURIComponent(JSON.stringify(value)); */
        }
        else {
            this._Storage.setItem(key, is_encode ? encodeURIComponent(value) : value);
        }
        return this;
    };
    /**
     * 获取localStorage对象或者sessionStorage对象的属性(键名)内容
     * @param {string} key
     * @param {boolean} decode 是否给字符串解码
     * @returns {*}
     */
    this.get = function (key, decode) {
        if (!key) {
            return this._Storage;
        }
        var copy = "", data = "";
        copy = data = decode ? decodeURIComponent(this._Storage.getItem(key)) : this._Storage.getItem(key);
        /*或者这样写: var data= decode ? this._Storage[key] : decodeURIComponent(this._Storage[key]); */
        try {
            data = JSON.parse(data);
        }
        catch (error) {
            console.log("错误！" + error.message);
        }
        return is_object(data) || is_array(data) ? data : copy;
    };
    /**
     * 移除localStorage对象或者sessionStorage对象的属性(键名)内容
     * @param {string} key
     * @param {boolean} mode 是否移除全部属性
     * @returns {storage}
     */
    this.remove = function (key, mode) {
        /*默认移除指定的localStorage或sessionStorage内容*/
        (key) || (mode = true);
        mode ? this._Storage.clear() : this._Storage.removeItem(key);
        return this;
    };
    /**
     * 遍历localStorage对象或者sessionStorage对象的属性(键名)内容
     * @param {function} fun 回调函数，传入2个参数【@key (键名),@value (键值)】
     * @returns {storage}
     */
    this.foreach = function (fun) {
        for (var i = 0, len = this._Storage.length; i < len; i++) {
            var key = this._Storage.key(i);
            var value = this.get(key);
            is_function(fun) && fun.call(this, key, value);
        }
        return this;
    };
}

/*标签选择器 @search string 类似css选择器 @parentE object 选择范围*/
window.eleGET=function(search,parentE){
    var allE=is_object(parentE) ? parentE.getElementsByTagName('*') : document.getElementsByTagName('*');
    var preg={
        "class"				: /\.[A-Za-z_][A-Z_a-z0-9\-]*/
        ,"id"				: /#[A-Za-z_][A-Z_a-z0-9\-]*/
        ,"ele"				: /[A-Za-z_][A-Z_a-z0-9\-]*/
        ,"child"			: />/g
        ,"attribute"		: /[\.#A-Za-z_]*[A-Z_a-z0-9\-]*\[[A-Z_a-z0-9\-]+=[!-z\u4e00-\u9fa5]+\]/
        ,"attributePreg"	: /[\.#A-Za-z_]*[A-Z_a-z0-9\-]*\[[A-Z_a-z0-9\-]+\*=[!-z\u4e00-\u9fa5]+\]/
    };
    var fun={
        class : function(){
            if(!preg.class.test(search)){return [];}
            search=search.replace(".","");
            var sE=[],j=0;
            foreach(allE,function(allE,i,value){
                (value.className===search)&&(sE[j]=value)&&(j++);
            });
            return sE;
        }
        ,id : function(){
            if(!preg.id.test(search)){return [];}
            search=search.replace("#","");
            return document.getElementById(search);
        }
        ,ele : function(){
            if(!preg['ele'].test(search)){return [];}
            var sE=[],j=0;
            foreach(allE,function(arr,i,value){
                (value.tagName.toLowerCase()===search.toLowerCase())&&(sE[j]=value)&&(j++);
            });
            return sE;
        }
        ,child : function(){
            // if(!preg['child'].test(search)){return [];}
            search=search.replace(/ /g,"");
            var searchArr=search.split(">");
            var eleContainer=[];
            var arrE=[ fun.screen(allE,searchArr[0]) ];
            var o={
                len:searchArr.length
                ,j:0
                ,i:0
                ,arr:[]
            };
            if(o.len>1){
                for(var i=1,j=0,len=o.len;i<len;i++,j++){
                    var searchs=searchArr[i];
                    (function(i,eArr){
                        foreach(eArr,function(arr1,i1,value1){
                            var childEle=value1.children;
                            childEle=fun.screen(childEle,searchs);
                            foreach(childEle,function(arr2,i2,value2){
                                o.arr[o.i]=value2; o.i++;
                            });
                        });
                    })(i,arrE[j]);
                    arrE[i]=o.arr;
                    o.arr=[]; o.i=0;
                }
            }
            var sE=arrE[o.len-1]; sE.type="child"; sE.getAll=arrE;
            return sE;

        }
        ,attribute : function(){
            //if(!preg['attribute'].test(search)){return [];}
            search=search.replace(/ /g,"");
            var l=search.split(/\[[A-Z_a-z0-9\-]+=[!-z\u4e00-\u9fa5]+\]/)[0];
            var r=search.match(/\[[A-Z_a-z0-9\-]+=[!-z\u4e00-\u9fa5]+\]?/g)[0];
            var r1=r;
            r=r.replace(/( |\[|\])/g,"");
            var k_v=r.split('=');
            var sE=[],o={j:0};
            // console.log(l,r,k_v[0],k_v[1])
            if (l) {
                // var select=this.eleGET(l);
                var select=fun.screen(allE,l);
                sE=fun.screen(select,r1);
            }
            else{
                foreach(allE,function(arr,i,value){
                    (value.getAttribute(k_v[0])===k_v[1])&&(sE[o.j]=value)&&(o.j++);
                });
            }
            return sE;

        }
        ,attributePreg : function(){
            search=search.replace(/ /g,"");
            var l=search.split(/\[[A-Z_a-z0-9\-]+\*=[!-z\u4e00-\u9fa5]+\]/)[0];
            var r=search.match(/\[[A-Z_a-z0-9\-]+\*=[!-z\u4e00-\u9fa5]+\]?/g)[0];
            var r1=r;
            r=r.replace(/( |\[|\])/g,"");
            var k_v=r.split('*=');
            var sE=[],o={j:0};
            // var preg=new RegExp(k_v[1]);
            // console.log(l,r,k_v[0],k_v[1])
            if (l) {
                var select_ele=fun.screen(allE,l);
                // console.log(select_ele,r1)
                sE=fun.screen(select_ele,r1);
                // console.log(sE);
            }
            else{
                sE=fun.screen(allE,r1);
            }
            return sE;
        }
        /*元素标签筛选*/
        ,screen : function(eleArr,search){
            if (!is_array(eleArr)) {return [];}
            var sE=[],o={j:0};
            if( /\[[A-Z_a-z0-9\-]+\*=[!-z\u4e00-\u9fa5]+\]/.test(search) ){
                var r=search.match(/\[[A-Z_a-z0-9\-]+\*=[!-z\u4e00-\u9fa5]+\]?/g)[0];
                r=r.replace(/( |\[|\])/g,"");
                var k_v=r.split("*=");
                // console.log("screen::",k_v[0],k_v[1])
                var pre=new RegExp(k_v[1]);
                foreach(eleArr,function(arr,i,value){
                    ( (pre.test(value[k_v[0]]))||(pre.test(value.getAttribute(k_v[0])) ) )&&(sE[o.j]=value)&&(o.j++);
                });
            }
            else if( /\[[A-Z_a-z0-9\-]+=[!-z\u4e00-\u9fa5]+\]/.test(search) ){
                var r=search.match(/\[[A-Z_a-z0-9\-]+=[!-z\u4e00-\u9fa5]+\]?/g)[0];
                r=r.replace(/( |\[|\])/g,"");
                var k_v=r.split("=");
                foreach(eleArr,function(arr,i,value){
                    ( (value[k_v[0]]===k_v[1])||(value.getAttribute(k_v[0])===k_v[1]) )&&(sE[o.j]=value)&&(o.j++);
                });
            }
            else if (preg.id.test(search)) {
                search=search.replace("#","");
                foreach(eleArr,function(arr,i,value){
                    (value.id===search)&&(sE[o.j]=value)&&(o.j++);
                });
            }
            else if(preg.class.test(search)){
                search=search.replace(".","");
                foreach(eleArr,function(arr,i,value){
                    (value.className===search)&&(sE[o.j]=value)&&(o.j++);
                });
            }
            else{
                foreach(eleArr,function(arr,i,value){
                    (value.tagName.toLowerCase()===search.toLowerCase())&&(sE[o.j]=value)&&(o.j++);
                });
            }
            return sE;

        }
    };
    if (preg.child.test(search)) {
        return fun.child.call(this);
    }
    else if (preg.attribute.test(search)) {
        return fun.attribute.call(this);
    }
    else if(preg.attributePreg.test(search)){
        return fun.attributePreg.call(this);
    }
    else if(preg.id.test(search)){
        return fun.id.call(this);
    }
    else if(preg.class.test(search)){
        return fun.class.call(this);
    }
    else{
        return fun.ele.call(this);
    }
}

/**
 * 监听对象属性值的变化和属性的获取
 * @param {object} obj 要监听的对象
 * @param {string} key 对象的属性（键名）
 * @param {function} getfun 获取对象属性值要执行的回调函数(可以不填)
 * @param {function} setfun 改变对象属性值时要执行的回调函数（可以不填）
 */
window.attributeListener = function (obj, key, getfun, setfun, c) {
    try {
        var temp_key = "temp__" + key + "__";
        obj[temp_key] = obj[key];
        c || (c = {});
    } catch (e) {
        console.log(e);
    }
    var o = {
        /*监听对象属性被获取时 get属性是自带的*/
        get: function () {
            is_function(getfun) && getfun.call(obj, obj[temp_key]);
            /*console.log("监听了 " + key + " 属性");*/
            return obj[temp_key];
        }
        /*监听对象属性值改变 set属性是自带的，是一个回调函数，传入一个值（即有一个参数）*/
        , set: function (newValue) {
            obj[temp_key] = newValue;
            is_function(setfun) && setfun.call(obj, newValue);
            /*console.log(newValue,arguments);*/
        }
    };
    ("value" in c) && (o.value = c.value);
    ("writable" in c) && (o.writable = c.writable);
    ("configurable" in c) && (o.configurable = c.configurable);
    ("enumerable" in c) && (o.enumerable = c.enumerable);

    Object.defineProperty(obj, key, o);
    /*Object.defineProperty.call(obj,obj,key,o);*/
};

/*
*动画
*/
function plug_move(){
    /*
    *t  当前时间 (time) 初始时间
    *b  初始位置 (beginning position)		(固定)
    *c  距离 (change position) 运动的距离	(固定)
    *d  持续时间 (duration)运动多少时间		(固定)
    *p  最终位置 (position)
    */
    var _obj=this;
    this.getCSS=function(obj,style_attr){
        return window.getComputedStyle ? getComputedStyle(obj)[style_attr] : obj.currentStyle[style_attr] ;
    }
    this.move_time={
        /*
        *tween算法 (基于时间的动画)
        */
        linear:function(t,b,c,d){ 			//匀速
            return c*t/d + b; //kx+b
        }
        ,easeIn: function(t, b, c, d){  	//加速曲线 ease前进的意思
            return c*(t/=d)*t + b;
        }
        ,easeOut: function(t, b, c, d){  	//减速曲线
            return -c *(t/=d)*(t-2) + b;
        }
        ,easeBoth: function(t, b, c, d){  	//加速减速曲线
            if ((t/=d/2) < 1) {
                return c/2*t*t + b;
            }
            return -c/2 * ((--t)*(t-2) - 1) + b;
        }
        ,easeInStrong: function(t, b, c, d){  //加加速曲线
            return c*(t/=d)*t*t*t + b;
        }
        ,easeOutStrong: function(t, b, c, d){  //减减速曲线
            return -c * ((t=t/d-1)*t*t*t - 1) + b;
        }
        ,easeBothStrong: function(t, b, c, d){  //加加速减减速曲线
            if ((t/=d/2) < 1) {
                return c/2*t*t*t*t + b;
            }
            return -c/2 * ((t-=2)*t*t*t - 2) + b;
        }
        ,elasticIn: function(t, b, c, d, a, p){  //正弦衰减曲线（弹动渐入）
            if (t === 0) {
                return b;
            }
            if ( (t /= d) == 1 ) {
                return b+c;
            }
            if (!p) {
                p=d*0.3;
            }
            if (!a || a < Math.abs(c)) {
                a = c;
                var s = p/4;
            } else {
                var s = p/(2*Math.PI) * Math.asin (c/a);
            }
            return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
        }
        ,elasticOut: function(t, b, c, d, a, p){    //正弦增强曲线（弹动渐出）
            if (t === 0) {
                return b;
            }
            if ( (t /= d) == 1 ) {
                return b+c;
            }
            if (!p) {
                p=d*0.3;
            }
            if (!a || a < Math.abs(c)) {
                a = c;
                var s = p / 4;
            } else {
                var s = p/(2*Math.PI) * Math.asin (c/a);
            }
            return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
        }
        ,elasticBoth: function(t, b, c, d, a, p){
            if (t === 0) {
                return b;
            }
            if ( (t /= d/2) == 2 ) {
                return b+c;
            }
            if (!p) {
                p = d*(0.3*1.5);
            }
            if ( !a || a < Math.abs(c) ) {
                a = c;
                var s = p/4;
            }
            else {
                var s = p/(2*Math.PI) * Math.asin (c/a);
            }
            if (t < 1) {
                return - 0.5*(a*Math.pow(2,10*(t-=1)) *
                    Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
            }
            return a*Math.pow(2,-10*(t-=1)) *
                Math.sin( (t*d-s)*(2*Math.PI)/p )*0.5 + c + b;
        }
        ,backIn: function(t, b, c, d, s){     //回退加速（回退渐入）
            if (typeof s == 'undefined') {
                s = 1.70158;
            }
            return c*(t/=d)*t*((s+1)*t - s) + b;
        }
        ,backOut: function(t, b, c, d, s){
            if (typeof s == 'undefined') {
                s = 3.70158;  //回缩的距离
            }
            return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
        }
        ,backBoth: function(t, b, c, d, s){
            if (typeof s == 'undefined') {
                s = 1.70158;
            }
            if ((t /= d/2 ) < 1) {
                return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
            }
            return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
        }
        ,bounceIn: function(t, b, c, d){    //弹球减振（弹球渐出）
            return c - this['bounceOut'](d-t, 0, c, d) + b;
        }
        ,bounceOut: function(t, b, c, d){
            if ((t/=d) < (1/2.75)) {
                return c*(7.5625*t*t) + b;
            } else if (t < (2/2.75)) {
                return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
            } else if (t < (2.5/2.75)) {
                return c*(7.5625*(t-=(2.25/2.75))*t + 0.9375) + b;
            }
            return c*(7.5625*(t-=(2.625/2.75))*t + 0.984375) + b;
        }
        ,bounceBoth: function(t, b, c, d){
            if (t < d/2) {
                return this['bounceIn'](t*2, 0, c, d) * 0.5 + b;
            }
            return this['bounceOut'](t*2-d, 0, c, d) * 0.5 + c*0.5 + b;
        }
        /*调用该函数 方法（move）执行动画*/
        ,move:function(obj,json_att,times,mode,is_scroll,fun){
            (!times)&&(times=500);
            (!mode)&&(mode="easeOut");
            if ((!obj && !json_att) && typeof obj!="object" && typeof json_att!="object") {return false;}
            //var previous=new Date();//以前的时间
            var current=new Date();//现在的时间
            /*获取初始值*/
            var iCur={};
            for(var att in json_att){
                if (is_scroll) {/*滚动条*/
                    iCur[att]=obj[att];
                }
                else{
                    att==="opacity" ? iCur[att] = Math.round(_obj.getCSS(obj,att)*100) : iCur[att] = parseInt(_obj.getCSS(obj,att));
                }
            }
            /*先清除上一个定时器*/
            //clearTimeout(this.Timeout);
            clearInterval(obj.Timeout);
            this.m=function(){
                /*获取t、d参数*/
                var d=times;
                var t=d-Math.max(0,current-(+new Date())+d);
                for(var attr in json_att){
                    /*获取b、c、p这三个参数*/
                    var b=iCur[attr];
                    var c=json_att[attr]-iCur[attr];
                    var p=_obj.move_time[mode](t,b,c,d);
                    /*赋值操作*/
                    if (is_scroll) {
                        obj[attr]=p;
                    }
                    else{
                        if (attr=="opacity") {
                            obj.style.opacity = p / 100;
                            obj.style.filter = 'alpha(opacity=' + p + ')';
                        }
                        else{
                            obj.style[attr] = p + 'px';
                        }
                    }

                }
                //obj.Timeout=setInterval(this.m,1000/60);
                //console.log(times,t,d);
                if (t==d) {
                    /*清除定时器*/
                    clearInterval(obj.Timeout);
                    fun && fun.call(obj);
                }
            }
            //this.Timeout=setTimeout(this.m,1000/60);
            obj.Timeout=setInterval(this.m,1000/60);
            //this.m.call(this);
        }
    };
    this.move=function(obj,json_att,times,mode,is_scroll,fun){
        this.move_time.move(obj,json_att,times,mode,is_scroll,fun);
    }
    /*函数里面的函数 里面的this默认指向window对象*/
    /*json_att,是一个一维对象,存放结束的位置,属性对应着传入的对象的运动属性*/
    /*示例： var move=new plug_move();  move.move(obj,{width:xxx,att2:xx..},500,"linear");*/
}

/**
 * js动画 构造函数
 * @obj object 要运动的对象
 * @json_attr object 运动对象的属性(键名)的终点位置
 * @times number 动画时间 （默认时间为 500 毫秒）
 * @move_type string 运动曲线名称（可以为空，默认值是 easeOut）
 * @is_scroll boolem|0|1 对象属性是否是无单位（可以为空，默认存在单位）
 * @fun function 动画完成后的回调函数（可以为空）
*/
function animation(){
    var tween={
        /*
        *tween算法 (基于时间的动画)
        */
        linear:function(t,b,c,d){           //匀速
            return c*t/d + b; //kx+b
        }
        ,easeIn: function(t, b, c, d){      //加速曲线 ease前进的意思
            return c*(t/=d)*t + b;
        }
        ,easeOut: function(t, b, c, d){     //减速曲线
            return -c *(t/=d)*(t-2) + b;
        }
        ,easeBoth: function(t, b, c, d){    //加速减速曲线
            if ((t/=d/2) < 1) {
                return c/2*t*t + b;
            }
            return -c/2 * ((--t)*(t-2) - 1) + b;
        }
        ,easeInStrong: function(t, b, c, d){  //加加速曲线
            return c*(t/=d)*t*t*t + b;
        }
        ,easeOutStrong: function(t, b, c, d){  //减减速曲线
            return -c * ((t=t/d-1)*t*t*t - 1) + b;
        }
        ,easeBothStrong: function(t, b, c, d){  //加加速减减速曲线
            if ((t/=d/2) < 1) {
                return c/2*t*t*t*t + b;
            }
            return -c/2 * ((t-=2)*t*t*t - 2) + b;
        }
        ,elasticIn: function(t, b, c, d, a, p){  //正弦衰减曲线（弹动渐入）
            if (t === 0) {
                return b;
            }
            if ( (t /= d) == 1 ) {
                return b+c;
            }
            if (!p) {
                p=d*0.3;
            }
            if (!a || a < Math.abs(c)) {
                a = c;
                var s = p/4;
            } else {
                var s = p/(2*Math.PI) * Math.asin (c/a);
            }
            return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
        }
        ,elasticOut: function(t, b, c, d, a, p){    //正弦增强曲线（弹动渐出）
            if (t === 0) {
                return b;
            }
            if ( (t /= d) == 1 ) {
                return b+c;
            }
            if (!p) {
                p=d*0.3;
            }
            if (!a || a < Math.abs(c)) {
                a = c;
                var s = p / 4;
            } else {
                var s = p/(2*Math.PI) * Math.asin (c/a);
            }
            return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
        }
        ,elasticBoth: function(t, b, c, d, a, p){
            if (t === 0) {
                return b;
            }
            if ( (t /= d/2) == 2 ) {
                return b+c;
            }
            if (!p) {
                p = d*(0.3*1.5);
            }
            if ( !a || a < Math.abs(c) ) {
                a = c;
                var s = p/4;
            }
            else {
                var s = p/(2*Math.PI) * Math.asin (c/a);
            }
            if (t < 1) {
                return - 0.5*(a*Math.pow(2,10*(t-=1)) *
                    Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
            }
            return a*Math.pow(2,-10*(t-=1)) *
                Math.sin( (t*d-s)*(2*Math.PI)/p )*0.5 + c + b;
        }
        ,backIn: function(t, b, c, d, s){     //回退加速（回退渐入）
            if (typeof s == 'undefined') {
                s = 1.70158;
            }
            return c*(t/=d)*t*((s+1)*t - s) + b;
        }
        ,backOut: function(t, b, c, d, s){
            if (typeof s == 'undefined') {
                s = 3.70158;  //回缩的距离
            }
            return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
        }
        ,backBoth: function(t, b, c, d, s){
            if (typeof s == 'undefined') {
                s = 1.70158;
            }
            if ((t /= d/2 ) < 1) {
                return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
            }
            return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
        }
        ,bounceIn: function(t, b, c, d){    //弹球减振（弹球渐出）
            return c - this['bounceOut'](d-t, 0, c, d) + b;
        }
        ,bounceOut: function(t, b, c, d){
            if ((t/=d) < (1/2.75)) {
                return c*(7.5625*t*t) + b;
            } else if (t < (2/2.75)) {
                return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
            } else if (t < (2.5/2.75)) {
                return c*(7.5625*(t-=(2.25/2.75))*t + 0.9375) + b;
            }
            return c*(7.5625*(t-=(2.625/2.75))*t + 0.984375) + b;
        }
        ,bounceBoth: function(t, b, c, d){
            if (t < d/2) {
                return this['bounceIn'](t*2, 0, c, d) * 0.5 + b;
            }
            return this['bounceOut'](t*2-d, 0, c, d) * 0.5 + c*0.5 + b;
        }        
    };

    var self=this; var _this=this;
    this.getName=function(name){
        var arr=[],i=0;
        for(var attr in tween){
            arr[i]=attr;
            i++;
        }
        return arr.indexOf(name)==-1 ? arr : name; 
    }
    this.autoType=function(name){
        if (is_array(name)) {return name[~~(Math.random()*(name.length))]; }
        var v=self.getName(name);
        return is_array(v) ? v[~~(Math.random()*(v.length))] : v;
    }
    this.getCSS=function(obj,style_attr){
        return window.getComputedStyle ? getComputedStyle(obj)[style_attr] : obj.currentStyle[style_attr] ;
    }
    this.move=function(obj,json_attr,times,move_type,is_scroll,fun){
        // 默认动画时间为500毫秒
        (!times)&&(times=500);
        // 默认运动曲线（方式）
        (!move_type)&&(move_type="easeOut");
        if ((!obj && !json_attr) && typeof obj!="object" && typeof json_attr!="object") {return false;}
        //var previous=new Date();//以前的时间
        var current=new Date();//现在的时间
        /*获取初始值*/
        var iCur={};
        for(var att in json_attr){
            if (is_scroll) {/*滚动条*/
                iCur[att]=obj[att];
            }
            else{
                att==="opacity" ? iCur[att] = Math.round(self.getCSS(obj,att)*100) : iCur[att] = parseInt(self.getCSS(obj,att));
            }
        }
        function action(){
            /*获取t、d参数*/
            var d=times;
            var t=d-Math.max(0,current-(+new Date())+d);
            for(var attr in json_attr){
                /*获取b、c、p这三个参数*/
                var b=iCur[attr];
                var c=json_attr[attr]-iCur[attr];
                var p=tween[move_type](t,b,c,d);
                // var p=tween[self.autoType(move_type)](t,b,c,d);
                /*赋值操作*/
                if (is_scroll) {
                    obj[attr]=p;
                }
                else{
                    if (attr=="opacity") {
                        obj.style.opacity = p / 100;
                        obj.style.filter = 'alpha(opacity=' + p + ')';
                    }
                    else{
                        obj.style[attr] = p + 'px';
                    }
                }

            }
            //console.log(times,t,d);
            if (t==d) {
                /*清除定时器*/
                clearInterval(obj.intervalID);
                fun && fun.call(obj);
            }            
        }
        clearInterval(obj.intervalID);
        obj.intervalID=setInterval(action ,1000/60);
    }
    this.automove=function(obj,json_attr,times,move_type,is_scroll,fun){
        // 默认动画时间为500毫秒
        (!times)&&(times=500);
        if ((!obj && !json_attr) && typeof obj!="object" && typeof json_attr!="object") {return false;}
        //var previous=new Date();//以前的时间
        var current=new Date();//现在的时间
        /*获取初始值*/
        var iCur={};
        for(var att in json_attr){
            if (is_scroll) {/*滚动条*/
                iCur[att]=obj[att];
            }
            else{
                att==="opacity" ? iCur[att] = Math.round(self.getCSS(obj,att)*100) : iCur[att] = parseInt(self.getCSS(obj,att));
            }
        }
        var type=self.autoType(move_type);
        function action(){
            /*获取t、d参数*/
            var d=times;
            var t=d-Math.max(0,current-(+new Date())+d);
            for(var attr in json_attr){
                /*获取b、c、p这三个参数*/
                var b=iCur[attr];
                var c=json_attr[attr]-iCur[attr];
                var p=tween[type](t,b,c,d);
                // var p=tween[self.autoType(move_type)](t,b,c,d);
                /*赋值操作*/
                if (is_scroll) {
                    obj[attr]=p;
                }
                else{
                    if (attr=="opacity") {
                        obj.style.opacity = p / 100;
                        obj.style.filter = 'alpha(opacity=' + p + ')';
                    }
                    else{
                        obj.style[attr] = p + 'px';
                    }
                }

            }
            //console.log(times,t,d);
            if (t==d) {
                /*清除定时器*/
                clearInterval(obj.intervalID);
                fun && fun.call(obj);
            }            
        }
        clearInterval(obj.intervalID);
        obj.intervalID=setInterval(action ,1000/60);
    }
}
/**
 * 代替用户点击操作事件 ele.click(); 这个是直接触发点击事件的(相当与用户点击了改元素标签)
 */

function inputFileSelect(inputEle) {
    if (is_object(inputEle)){
        inputEle.click();
    }
    else{
        try {
            eleGET(inputEle)[0].click();
        }catch (e) {
            console.log(e);
        }
    }
}

/**
 * @param obj  二维数组及多维数组
 * @param field  设置某个字段的值为 数组下标
 * @returns {*}
 */
function reconfig_array(obj,field){
    if(!field){return;}
    var arr = {};
    if(is_object(obj) || is_array(obj)){
        for(var attr in obj){
            arr[ obj[attr][field] ] = obj[attr];
            //obj[ obj[attr][field] ] = obj[attr];
        }
        return arr;
    }
}

/**
 * 删除左右两端的空格
 * @param {string} str
 * @param {string} preg
 * @returns {void | string | *}
 */
function trim(str, preg) {
    if (preg) {
        preg = new RegExp("(^" + preg + "*|" + preg + "*$)", "ig");
    }
    (preg) || (preg = /(^[\s\t\r\n]*|[\s\t\r\n]*$)/ig);
    return str.replace(preg, "");
}

/**
 * 删除左侧的空格
 * @param {string} str
 * @param {string} preg
 * @returns {void | string | *}
 */
function ltrim(str, preg) {
    if (preg) {
        preg = new RegExp("(^" + preg + "*)", "ig");
    }
    (preg) || (preg = /(^[\s\t\r\n]*)/i);
    return str.replace(preg, "");
}

/**
 * 删除右侧的空格
 * @param {string} str
 * @param {string} preg
 * @returns {void | string | *}
 */
function rtrim(str, preg) {
    if (preg) {
        preg = new RegExp("(" + preg + "*$)", "ig");
    }
    (preg) || (preg = /([\s\t\r\n]*$)/i);
    return str.replace(preg, "");
}

function my_get_url_data(str,key,clear_key,lv1,lv2) {
    (lv1) || (lv1 = "&");
    (lv2) || (lv2 = "=");
    var arr = str.split(lv1);
    var data = {};
    for (var i=0,len= arr.length;i<len;i++){
        var d = arr[i].split(lv2);
        if(d.length > 2){
            for(var j=1,j1=0,_len=d.length,_d=[];j<_len;j++,j1++){
                _d[j1] = d[j];
            }
            d[1] = _d.join(lv2);
        }
        data[d[0]] = d[1];
    }
    delete data[""];
    if (clear_key){
        delete data[clear_key];
    }
    return key ? data[key] : data;
}
/**
 * 获取 get 参数
 * @param key
 * @param clear_key
 * @returns {*}
 */
function get_url_data(key,clear_key) {
    var search = location.search.substr(1);//get参数部分字符串
    var arr = search.split('&');
    var data = {};
    for (var i=0,len= arr.length;i<len;i++){
        var d = arr[i].split("=");
        data[d[0]] = d[1];
    }
    if (clear_key){
        delete data[clear_key];
    }
    return key ? data[key] : data;
}
function set_url_data(obj,lv1,lv2) {
    (lv1) || (lv1 = "&");
    (lv2) || (lv2 = "=");
    var get_str = "";
    if (obj){
        for (var attr in obj){
            get_str += attr + lv2 + obj[attr] + lv1;
        }
    }
    return get_str;
}


/**
 * cookie 的操作
 */
function cookies() {
    if (arguments.length>0) {
        for(var i=0,len=arguments.length;i<len;i++){
            if (typeof arguments[i]==="function") {
                arguments[i].call(this);
            }
            if (typeof arguments[i]==="object" && !("length" in arguments[i])) {
                for(var att in arguments[i]){
                    this[att]=arguments[i][att];
                }
            }
        }
    }
}
cookies.prototype = {
    /**
     * 设置cookie
     * @param c_key  键名
     * @param value  cookie的键值
     * @param time 设置cookie的有效时间
     * @param dir cookie的作用路径
     */
    setCookie: function (c_key, value, time, dir) {
        var t = new Date();
        var Day = time && typeof time === "number" ? time : 7;
        t.setTime(t.getTime() + Day * 24 * 60 * 60 * 1000);
        value = encodeURIComponent(value);
        document.cookie = dir ? c_key + "=" + value + ";expires=" + t.toGMTString() + ";path=" + dir : c_key + "=" + value + ";expires=" + t.toGMTString() + "path=/";
    }
    /**
     * 删除单个cookie
     * @param c_key
     * @param dir
     * @returns {string}
     */
    , delCookie: function (c_key, dir) {
        dir = dir ? dir : "/";
        this.setCookie(c_key, "", 0, dir);
        this.setCookie(c_key, "", -2, dir);
        return this.getCookie(c_key) ? "删除cookie失败！" + this.getCookie(c_key) : "删除cookie成功";
    }
    /**
     * 获取单个cookie
     * @param c_key
     * @returns {string}
     */
    , getCookie: function (c_key) {
        var arr = document.cookie.split("; ");
        //console.log(arr)
        var c_str = "";
        foreach(arr, function (arr, key, value) {
            var a = value.split("=");
            //console.log(a[0],a[1])
            if (a[0] === c_key) {
                c_str = a[1];
            }
        });
        console.log(c_str)
        return decodeURIComponent(c_str);
    }
    /**
     * 批量删除cookie
     * @param json 数组或对象
     */
    , delCookieAll: function (json) {
        if(!json || json == {} || json == []){
            var arr=document.cookie.split("; ");
            for(var i=0,len=arr.length;i<len;i++){
                var k=arr[i].split("=");
                this.delCookie(k[0]);
            }
        }else{
            foreach.call(this,json,function (arr,i,value) {
                this.delCookie(value);
            });
        }
    }
    /**
     * 批量获取cookie
     * return object
     */
    , getCookieAll: function () {
        var arr=document.cookie.split("; ");
        var arr_json={};
        foreach(arr, function (arr, key, value) {
            var arr1 = value.split("=");
            arr_json[arr1[0]] = arr1[1];
        });
        return arr_json;
    }
    /**
     * 批量设置cookie 使用方法如：cookie.setCookieAll([{c_key:"c_key1",value:"value1"},{c_key:"c_key2",value:"value2"}]);
     * @param object|array json 对象或二维数组
     * @param number t 时间天
     * @param string dir 路径
     */
    , setCookieAll: function (json,t,dir) {
        if(is_object(json) || is_array(json)){
            var self = this;
            foreach.call(this,json,function (arr,k,v) {
                if(is_object(v)){
                    t = v.time ? v.time : t;
                    dir = v.dir ? v.dir : dir;
                    self.setCookie(v.c_key, v.value, t, dir);
                }
            });
        }
    }
};

function EventUtil() {
    this.add = function (element,eventType,fn,boolean) {
        (boolean) || (boolean = false);
        element[eventType + "event_fn"] = fn;
        if (element.addEventListener) {
            element.addEventListener(eventType,element[eventType+"event_fn"],boolean);
        }else if (element.attachEvent){
            element.attachEvent("on"+eventType,element[eventType+"event_fn"]);
        }else{
            element["on"+eventType]=fn;
        }
    }
    this.remove = function (element,eventType,boolean) {
        (boolean) || (boolean = false);
        if (element.removeEventListener) {
            element.removeEventListener(eventType,element[eventType+"event_fn"], boolean);
        }else if (element.detachEvent){
            element.detachEvent("on" + eventType,element[eventType+"event_fn"]);
        } else{
            element["on"+eventType] = null;
        }
    }
    this.getEvent=function (event) {
        return event ? event : window.event;
    }
    this.getTarget=function (event) {
        return event ? event.target : event.srcElement;
    }
    this.preventDefault=function (event) {
        if (event.preventDefault) {
            event.preventDefault();
        }else{
            event.returnValue = false;
        }
    }
    this.stopPropagation = function (event) {
        if (event.stopPropagation) {
            event.stopPropagation();
        }else {
            event.cancelBubble = true;
        }

    }
}
EventUtil.prototype = {
    win:window
};


function search_keyword(config) {
	if(Object.prototype.toString.call(config) === "[object Object]"){
		for(var attr in config){
			this[attr] = config[attr];
		}
	}
}
search_keyword.prototype = {
    /**
     * 数组截取
     * @param  array array  [description]
     * @param  number start  [description]
     * @param  number length [description]
     * @return array        [description]
     */
    array_slice: function(array, start, length) {
        var arr = [];
        length = length < 0 ? 0 : length;
        for (var i = 0, j = 0, len = array.length; i < len; i++) {
            if (i >= start && i < length + start) {
                arr[j] = array[i];
                j++;
            }
        }
        return arr;
    },
    /**
     * 搜索词分割，左->右，字数由多到少
     * @param  {[type]} length   [description]
     * @param  {[type]} array    [description]
     * @param  {[type]} save_arr [description]
     * @return {[type]}          [description]
     */
    search1: function(length, array, save_arr) {
        for (var i = 0, len = array.length; i < len; i++) {
            (i + length <= len) && (save_arr[save_arr.length] = this.array_slice(array, i, length));
            //(i + length <= len) && (save_arr[save_arr.length] = array.slice(i, length));
        }
    },
    /**
     * 搜索词分割
     * @param  string keyword  [搜索词]
     * @param  boole|number toString [布尔值或者 0，1]
     * @return array          [返回数组]
     */
    keyword: function(keyword,toString) {
        var array = keyword.split('');
        var save_arr = [];
        var l, len;
        len = array.length;
        for (var i = len; i > 0; i--) {
            this.search1(i,array,save_arr);
        }
        if(toString){
        	for(var i = 0,len = save_arr.length;i<len;i++){
        		save_arr[i] = save_arr[i].join("");
        	}
        }
        return save_arr;
    },

    set_url_data: function(obj, lv1, lv2) {
        (lv1) || (lv1 = "&");
        (lv2) || (lv2 = "=");
        var get_str = "";
        if (obj) {
            for (var attr in obj) {
                get_str += attr + lv2 + obj[attr] + lv1;
            }
        }
        return get_str;
    },
    /**
     * 删除左右两端的空格
     * @param  {[type]} str  [description]
     * @param  {[type]} preg [description]
     * @return {[type]}      [description]
     */
    trim: function(str, preg) {
        if (preg) {
            preg = new RegExp("(^" + preg + "*|" + preg + "*$)", "ig");
        }
        (preg) || (preg = /(^[\s\t\r\n]*|[\s\t\r\n]*$)/ig);
        return str.replace(preg, "");
    }
};

/**
 * 插入 html
 * @param paramElement
 * @param {string|object} htmlCode
 * @param beforeElement
 * @returns {boolean}
 */
function addElement(paramElement, htmlCode, beforeElement) {
    var div = document.createElement('div');
    var doc = document.createDocumentFragment ? document.createDocumentFragment() : 0;
    if (htmlCode && paramElement) {
        if(is_object(htmlCode)){
            var ele = document.createElement(htmlCode.tagName);
            delete htmlCode.tagName;
            for(var attr in htmlCode){
                if(attr == "className"){
                    ele[attr] = htmlCode[attr];
                }else{
                    ele.setAttribute(attr,htmlCode[attr]);
                }
            }
            return beforeElement ? paramElement.insertBefore(ele, beforeElement) : paramElement.appendChild(ele);
        }
        div.innerHTML = htmlCode;
        //div.childNodes 会动态改变
        var div_child = div.childNodes ? div.childNodes : div.children;
        if (doc) {
            //console.log(1);
            for (var i = 0, len = div_child.length; i < len; i++) {
                (function (i) {
                    doc.appendChild(div_child[0]);
                })(i);
            }
            beforeElement ? paramElement.insertBefore(doc, beforeElement) : paramElement.appendChild(doc);
        } else {
            //console.log(0);
            for (var i = 0, len = div_child.length; i < len; i++) {
                doc.appendChild(div_child[0]);
                beforeElement ? paramElement.insertBefore(div_child[0], beforeElement) : paramElement.appendChild(div_child[0]);
            }
        }
    } else {
        return false;
    }
}

/**
 * 查看浏览器的 localStorage 能存储多少字符串
 * @param {number} str_leng 一次写入多少字符
 * @param {number} t 定时器间隔时间（秒）
 */
function localStorage_maxlen(str_leng,t) {
    if(!window.localStorage){
        console.log("当前浏览器不支持localStorage!");
        return false;
    }
    var k1 = "localStorage_maxlen_str_leng_001" , IDD = "localStorage_maxlen_str_leng_IDD" , T = "localStorage_maxlen_str_leng_time";
    window[k1] || (window[k1] = str_leng ? str_leng : 1024);
    window[T] || (window[T] = t ? t : 1000/60);
    clearTimeout(window[IDD]);
    var str = localStorage.getItem("str");
    str += randomString(window[k1],'ns');
    try {
        localStorage.setItem("str",str);
    }catch (e) {
        console.log("超出最大限制："+ (str.length/1024) +"KB,"+str.length+"个字符串");
        localStorage.removeItem("str");
        return false;
    }
    console.log((str.length/1024)+"KB");
    window[IDD] = setTimeout(function () {
        try {
            localStorage_maxlen();
        }catch (e) {
            console.log("超出最大限制："+ (str.length/1024) +"KB");
            clearTimeout(window["IDD"]);
        }
    },window[T]);
}

function chr_utf8(code) {
    return String.fromCharCode(code);
}

function ord_utf8(str) {
    return String.prototype.charCodeAt.call(str,0);
    //return String.prototype.charCodeAt.call(str);
}

/**
 * 字符串替换
 * @param {array|string|RegExp} search_str 模式 search_str
 * @param {array|string} replace_str 替换为 replace_str
 * @param {string} strings 要替换的字符串
 * @param {number} l 替换次数，值为-1的时候为全部替换
 * @returns {string}
 */
function str_replace(search_str, replace_str, strings, l) {
    if (Object.prototype.toString.call(search_str) === "[object Array]") {
        if (Object.prototype.toString.call(replace_str) === "[object Array]" && search_str.length == replace_str.length) {
            for (var i = 0, len = search_str.length; i < len; i++) {
                strings = str_replace(search_str[i], replace_str[i], strings, l);
            }
        }
    } else if (l > 1) {
        for (var i = 0; i < l; i++) {
            strings = str_replace(search_str, replace_str, strings);
        }
    } else {
        if (typeof replace_str === "string" || typeof replace_str === "number") {
            if (Object.prototype.toString.call(search_str) === "[object RegExp]") {
                if (l === -1) {
                    var tag = search_str.global ? "g" : "g";
                    (search_str.ignoreCase) && (tag += "i");
                    (search_str.multiline) && (tag += "m");
                    var reg = new RegExp(search_str.source, tag);
                    //console.log(reg);
                    strings = strings.replace(reg, replace_str);
                } else {
                    (search_str.global) || (strings = strings.replace(search_str, replace_str));
                }
            }
            else {
                if (l === -1) {
                    var reg = new RegExp(search_str.replace(/(\.|\*|\+|\?|\(|\)|\[|\]|\{|\}|\\|\/|\|)/gi, "\\$1"), "g");
                    //console.log(reg);
                    strings = strings.replace(reg, replace_str);
                } else {
                    strings = strings.replace(search_str, replace_str);
                }
            }
        }
    }
    return strings;
}

/**
 * 判断浏览器函数(是否是移动端)
 * @returns {boolean}
 */
function is_mobile(){
    if(window.navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {
        return true; // 移动端
    }else{
        return false; // PC端
    }
}

/**
 * 判断是否是微信浏览器的函数
 * @returns {boolean}
 */
function is_WeiXin() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
    }
    return false;
}

/**
 * 判断是支付宝app的浏览器
 * @returns {boolean}
 */
function is_alipay() {
    var userAgent = navigator.userAgent.toLowerCase();
    if (userAgent.match(/Alipay/i) == "alipay") {
        return true;
    }
    return false;
}

/**
 * js模拟post表单提交
 * @param {string} url
 * @param {object} params
 * @param {string} target 如:_blank
 * @returns {HTMLElement}
 */
function post(url, params, target) {
    var form = document.createElement("form");
    form.action = url;
    form.method = "post";
    form.style.display = "none";
    form.target = target && typeof target === "string" ? target : "";
    for (var attr in params) {
        var opt = document.createElement("input");
        opt.name = attr;
        opt.value = params[attr];
        form.appendChild(opt);
    }
    document.body.appendChild(form);
    form.submit();
    document.body.removeChild(form);
    return form;
}

/**
 * js模拟a标签get请求
 * @param {string} url
 * @param {object} params
 * @param {string} target 如:_blank
 */
function get(url, params, target) {
    var aE = document.createElement("a");
    var queryString = "";
    if (params && typeof params === "object") {
        for (var attr in params) {
            queryString += "&" + attr + "=" + params[attr];
        }
        queryString = "?" + queryString.replace(/^[&]*/i, "");
    }
    aE.href = url + queryString;
    aE.target = target && typeof target === "string" ? target : "";
    aE.style.display = "none";
    document.body.appendChild(aE);
    aE.click();
    document.body.removeChild(aE);
    return aE;
}

/**
 * 获取地址参数
 * @param {string} name
 * @param {string} option 选项值有[get,param]
 * @param {number} num option值为param时才有用，从第几项开始截取，最小值是0
 * @returns {*}
 */
function param(name, option, num) {
    (option) || (option = "get");
    (num) || (num = 0);
    if (option === "get") {
        if (!location.search) {
            location.search = location.href.match(/[?].*/i)[0];
        }
        var arr1 = decodeURIComponent(location.search.replace(/^\?/i, "")).split(/&/i);
        var arr2 = {};
        for (var i = 0, len = arr1.length; i < len; i++) {
            var k_v = arr1[i].split("=");
            arr2[k_v[0]] = arr1[i].replace(new RegExp("^" + k_v[0].replace(/([?.{}*\/\[\]+,\\()<>])/ig, "\\$1") + "=", "i"), "");
        }
        return name ? arr2[name] : arr2;
    }
    if (option === "param" && typeof num === "number" && num >= 0) {
        var trim = function (str, preg) {
            if (preg) {
                preg = new RegExp("(^" + preg + "*|" + preg + "*$)", "ig");
            }
            (preg) || (preg = /(^[\s\t\r\n]*|[\s\t\r\n]*$)/ig);
            return str.replace(preg, "");
        };
        var pathname = trim(decodeURIComponent(location.pathname), "\/");
        var arr1 = pathname.split(/\//);
        if (/([a-z_A-Z_0-9\-]+\.[a-zA-Z0-9]+)/i.test(arr1[0])) {
            arr1.shift();
        }
        var new_arr1 = [];
        for (var i = 0, len = arr1.length; i < len; i++) {
            if (i >= num) {
                new_arr1.push(arr1[i]);
            }
        }
        var arr2 = {};
        for (var i = 0, len = new_arr1.length; i < len; i++) {
            if (i % 2 === 0) {
                arr2[new_arr1[i]] = typeof new_arr1[i + 1] === "undefined" ? null : new_arr1[i + 1];
            }
        }
        return name ? arr2[name] : arr2;
    }
    return false;
}

/**
 * 打开新窗口（打开弹窗）
 * @param {string} url
 */
function open_window(url) {
    //设置新窗口的特性
    var features = "height=600, width=900, top=100, left=100, toolbar=no, menubar=no, scrollbars=no,resizable=no, location=no, status=no";
    window.open(url, "open1", features);
}

/**
 * ajax 参考链接：https://developer.mozilla.org/zh-CN/docs/Web/API/XMLHttpRequest
 * @param {string} url
 * @param {object} data
 * @param {string} method
 * @param {function} fn_success
 * @param {object} config
 */
function ajax(url, data, method, fn_success, config) {
    var conf = {
        method: method ? method : "GET",
        Async: true,
        url: url,
        contentType: true,
        processData: true,
    };
    if (is_object(config)) {
        for (var attr in config) {
            if (config.hasOwnProperty(attr)) {
                conf[attr] = config[attr];
            }
        }
    }
    var xhr = ajax.get_xhr();
    xhr.open(conf.method, conf.url, conf.Async);
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
            var return_data = {};
            return_data.xhr = xhr;
            return_data.data = xhr.responseText;
            is_function(fn_success) && fn_success.call(xhr, return_data);
            is_function(conf.readystatechange) && (conf.readystatechange.call(xhr, return_data));
            //console.log(return_data);
        }
    };
    //当 request 被停止时触发，例如当程序调用 XMLHttpRequest.abort() 时。
    xhr.onabort = function () {
        is_function(conf.abort) && conf.abort.call(xhr);
    };
    //当 request 遭遇错误时触发。
    xhr.onerror = function () {
        is_function(conf.error) && conf.error.call(xhr);
    };
    //XMLHttpRequest请求成功完成时触发。
    xhr.onload = function () {
        is_function(conf.load) && conf.load.call(xhr);
    };
    //当请求结束时触发, 无论请求成功 ( load) 还是失败 (abort 或 error)。
    xhr.onloadend = function () {
        is_function(conf.loadend) && conf.loadend.call(xhr);
    };
    //接收到响应数据时触发。
    xhr.onloadstart = function () {
        is_function(conf.loadstart) && conf.loadstart.call(xhr);
    };
    //当请求接收到更多数据时，周期性地触发。
    xhr.onprogress = function () {
        is_function(conf.progress) && conf.progress.call(xhr);
    };
    //在预设时间内没有接收到响应时触发。
    xhr.ontimeout = function () {
        is_function(conf.timeout) && conf.timeout.call(xhr);
    };
    if (conf.contentType === true) {
        xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    }
    if (conf.processData === true) {
        conf.send_str = ajax.url_data(data);
    }
    xhr.send(conf.send_str);
    return ajax;
}

ajax.get_xhr = function () {
    var xhr = null;
    if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return xhr;
};
ajax.url_data = function (data, lv1, lv2) {
    (lv1) || (lv1 = "&");
    (lv2) || (lv2 = "=");
    var str = "";
    if (is_object(data)) {
        for (var key in data) {
            str += lv1 + encodeURIComponent(key) + lv2 + encodeURIComponent(data[key]);
        }
        str = ltrim(str, lv1);
    }
    return str;
};
ajax.get = function (url, data, fn_success, config) {
    var Query = "";
    url = url.replace(/\?+.+$/ig, "");
    is_object(data) && (Query = ajax.url_data(data));
    ajax(url + "?" + Query, "", "get", fn_success, config);
};
ajax.post = function (url, data, fn_success, config) {
    ajax(url, data, "POST", fn_success, config);
};

try {
    var LO=new storage();
    var SE=new storage("sessionStorage");
    // var MOVE=new plug_move();
    var move=new animation();
    var Events = new EventUtil();
    var cookie = new cookies();
}catch (e) {

}